import request from '@/utils/request'
import {useTokenStore} from "@/stores/token";
// AI聊天流式接口
export async function aiChatStream(message) {
    const token = useTokenStore().token;
    const url = new URL('/api/ai/chatStream', window.location.origin)
    url.searchParams.set('message',message)

    const response = await fetch(url, {
        method: 'GET',
        headers: {
            Authorization: token
        }
    })

    if (!response.ok) {
        throw new Error(`HTTP error! status: ${response.status}`)
    }

    // 返回reader对象
    return response.body.getReader()
}
